package controller

import (
	"github.com/gin-gonic/gin"
	"my_music_server/common"
	"my_music_server/model"
	"my_music_server/service"
	"net/http"
)

var _fileService = &service.FileService{}

func UploadFile(c *gin.Context) {
	//单文件上传
	//歌曲文件
	songFile, _ := c.FormFile("songFile")
	lyricFile, _ := c.FormFile("lyricFile")
	coverFile, _ := c.FormFile("coverFile")
	//歌曲名称
	name := c.PostForm("name")
	singer := c.PostForm("singer")
	description := c.PostForm("description")

	song := &model.Song{
		Name:     name,
		Singer:   singer,
		Descript: description,
	}

	songFileURL := _fileService.Upload(songFile, lyricFile, coverFile, song, c)

	c.JSON(http.StatusOK, common.Ok().DataKV("songFileURL", songFileURL))
}
